<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <div id="app">
        <!-- <cpn :cmovies="movies" :cmessage="message"></cpn> -->
        <cpn :cmessage="message" :cmovies="movies"></cpn>
    </div>
    <template id="cpn">
        <div>
            <!-- <p>{{cmovies}}</p> -->
            <ul>
                <li v-for="item in cmovies">{{item}}</li>
            </ul>
            <h2>{{cmessage}}</h2>
        </div>
    </template>
    <script src="../js/vue.js"></script>
    <script>
        // 父传子：props
            const cpn = {
                template:'#cpn',
                // 数组方式
                // props:['cmovies','cmessage'],

                props:{
                    // 1.类型限制
                    // cmovies:Array,
                    // cmessage:String,

                    // 2.提供给一些默认值,以及必传值
                    cmessage:{
                        type:String,
                        default:"aaaaa",
                        required:true
                    },
                    // 类型是对象或者数组时，默认必须是一个函数
                    cmovies:{
                        type:Array,
                        // default:[] //2.5.2以下不会报错
                        default(){
                            return []
                        }
                    }
                },
                data(){
                    return{

                    }
                }
            }

        const app = new Vue({
            el:'#app',
            data:{
                message:'你好呀！',
                movies:['还望','海贼王',"海华"]
            },
            components:{
                cpn
            }
        })


// 字面量的增强写法
    //  const name = "ss"
    //     const obj = {
    //         name
    //     }
    </script>
</body>
</html>